﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.IO;

namespace RN.ERP.Web.Handlers
{
    public class MessageHelper
    {
        private static string MsgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Handlers/Msg.xml");
        
        public static string GetMsg(string key)
        {
            XDocument doc = XDocument.Load(MsgPath);
            XElement ele = doc.Root.Elements("msg").FirstOrDefault(m => m.Attribute("key").Value == key);
            if (ele != null)
            {
                return ele.Value;
            }
            
            return null;
        }

        public string this[string key]
        {
            get
            {
                return GetMsg(key);
            }
        }
    }
}